<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false" %>
<%@include file="/jsp/common/head.jsp"%>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/myinfo.css"/>
<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>个人信息页面</span>
    </div>
    <div class="d1">
        <ul class="msg">
            <li>
                <span class="label">名字</span>
                <span class="label2">
                    <input type="text" id="nickname" class="nickname" value="${userSession.nickname}"/>
                </span>
                <a href="#">修改</a>
            </li><br><br>
            <li>
                <span class="label">邮箱</span>
                <span class="label2">${userSession.mail}</span>
            </li><br><br>
            <li>
                <span class="label">密码</span>
                <span class="label2">********</span>
                <a href="#">修改</a>
            </li>
        </ul>
        <form id="passwdChange" action="${pageContext.request.contextPath}/updatePasswd" style="display: none">
            <span>原密码</span><br>
            <input type="password" id="oldpasswd" name="oldpasswd" style="width: 200px;height: 30px" onblur="compareWold()" required/>
            <span id="s1" style="color: red"></span>
            <br><br>
            <span>新密码</span><br>
            <input type="password" id="newpasswd" name="newpasswd" style="width: 200px;height: 30px" onblur="standard()"
                  placeholder="包含数字和字母,在8-16位之间" required/>
            <span id="s2" style="color: red"></span>
            <br><br>
            <span>请再次输入密码</span><br>
            <input type="password" id="passwdcheck" name="passwdcheck" style="width: 200px;height: 30px" oninput="check()"
                  placeholder="两次输入的密码必须一致" required/>
            <span id="s3" style="color: red"></span>
            <br><br>
            <span>请输入验证码</span><br>
            <input type="text" id="code" name="code" onblur="update()" style="width: 100px;height: 30px;margin-right: 23px" required/>
            <button id="btn2" onclick="time(this)" style="height: 30px;width: 70px">发送验证码</button><br>
            <input type="submit" value="修改" style="margin-top: 20px;width: 200px;height: 30px;">
        </form>
    </div>
</div>
</section>
<%@include file="/jsp/common/foot.jsp" %>
<script>
    var password = '${userSession.password}'
    var code = ""
    var name = '${userSession.nickname}'
    function time(o) {
        o.setAttribute("disabled","true");
        o.innerHTML = "已发送"
        setTimeout(function (){
            o.removeAttribute("disabled")
            o.innerHTML = "发送验证码"
        },60*1000)
        $.ajax({
            type:"get",
            url:"${pageContext.request.contextPath}/sendCode",
            success:function (data) {
                code=data
                setTimeout(function () {
                    code=''
                },5*60*1000)
            }
        })
    }
    var $a = $(".msg").find('li').eq(0).find('a');
    $a.click(function(){
        var nickname = $('#nickname').val();
        if(nickname!=name){
            $.ajax({
                type:'get',
                url:'${pageContext.request.contextPath}/updateName',
                async:false,
                data:{"nickname":nickname},
            })
        }
    })
</script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/myinfo.js">
</script>
